import { getAllArtwork,getAllArtworkFake,getBannersFake, getShopByClassifyAndForm, getAds } from "@/api"

const state = {
    allArtworks:[],
    banners:[],
    sellingArtworks:{},
    filterOptions:{
        pageSize: "2",
        pageIndex: "1",
        user_address: "",
        classify:"所有",
        form_of_sale:"所有",
        minprice:0,
        maxprice:1000000
    }
}

const mutations = {
    ALLARTWORKS(context,data){
        context.allArtworks = data
    },
    BANNERS(context, data){
        context.banners = data
    },
    SELLINGARTWORKS(context, data){
        context.sellingArtworks = data
    },
    FILTEROPTIONS(context, data){
        context.filterOptions = data
    }
}

const actions = {
    async allArtworks({commit},queryData){
        let result = await getAllArtworkFake(queryData)
        commit("ALLARTWORKS", result)
    },
    async banners({commit}){
        // 获取轮播图
        // let result = await getBannersFake()
        let result = await getAds()
        commit('BANNERS', result)
    } ,
    async sellingArtworks({commit}, queryData){
        commit("FILTEROPTIONS", queryData)
        let result = await getShopByClassifyAndForm(queryData)
        commit("SELLINGARTWORKS", result)
    }
}

const getters = {}

export default {
    state,
    mutations,
    actions,
    getters
}